package demo.day07

// Kotlin 语言的主构造函数学习
fun main() {
    val ktBase02 = KtBase02("Ki", 'n', 18, "shahsahjhj")
    ktBase02.name = "123456"
    ktBase02.sex = '2'
    ktBase02.age = 28
    ktBase02.info = "卷死他们"
    println(ktBase02.name)
    println(ktBase02.sex)
    println(ktBase02.age)
    println(ktBase02.info)
}

/**
 * 主构造函数 规范来说 都是增加_xxx的方式 临时输入类型 不能直接使用
 * 想使用的话 需要变量来接受
 */
class KtBase02(_name: String, _sex: Char, _age: Int, _info: String) {
    var name = _name
        get() = field
        set(value) {
            field = value
        }
    var sex = _sex
        get() = field
        set(value) {
            field = value
        }
    var age = _age
        get() = field
        set(value) {
            field = value
        }
    var info = _info
        get() = field
        set(value) {
            field = value
        }
}